package com.unknown.wificontrol.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.unknown.wificontrol.R;

import me.majiajie.pagerbottomtabstrip.item.BaseTabItem;

public class TabTitleItem extends BaseTabItem {

    private final TextView mTitle;
    private final ImageView mIcon;
    private int mDefaultDrawable;
    private int mCheckedDrawable;

    private int mDefaultColor;
    private int mCheckedColor;

    public TabTitleItem(@NonNull Context context, @DrawableRes int drawableRes, @DrawableRes int checkedDrawableRes, String title) {
        super(context);
        LayoutInflater.from(context).inflate(R.layout.layout_tab_custom_layout_item, this, true);
        mTitle = findViewById(R.id.tv_title);
        mIcon = findViewById(R.id.iv_icon);
        mDefaultColor = ContextCompat.getColor(context, R.color.tab_unselect_color);
        mCheckedColor = ContextCompat.getColor(context, R.color.tab_select_color);
        mDefaultDrawable = drawableRes;
        mCheckedDrawable = checkedDrawableRes;
        mTitle.setText(title);
    }


    @Override
    public void setChecked(boolean checked) {
        mIcon.setImageResource(checked ? mCheckedDrawable : mDefaultDrawable);
        mTitle.setTextColor(checked ? mCheckedColor : mDefaultColor);
    }

    @Override
    public void setMessageNumber(int number) {

    }

    @Override
    public void setHasMessage(boolean hasMessage) {

    }

    @Override
    public String getTitle() {
        return mTitle.getText().toString();
    }
}
